<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display"%>
<%@ taglib uri="/WEB-INF/config/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="http://ssh.org/selects" prefix="ssh"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
String applicationPath = basePath + "/" + "application";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<link href="<%=path%>/css/jinmu_style.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='<%=path%>/frame/orgSelect/js/ajaxInitSelect.js'></script>
<script language="javascript" src="<%=path%>/js/util.js"></script>
<script language="javascript" src="<%=path%>/js/SyncCommon.js"></script>
<script language="javascript" src="<%=path%>/js/dictionary.js"></script>
		<style>
html { overflow-x: hidden; overflow-y: auto; }
</style>

</head>
<body>
<html:form styleId="projectworksheetsForm" action="updateProjectworksheets.do?method=updateProjectworksheets" onsubmit="return save();">

<input type ="hidden" id="id" name="id" value="${projectworksheets.id}"/>
<input type ="hidden" name="rfpsid" id="rfpsid"  value="${projectworksheets.rfpsid}"/>
<input type ="hidden" id="worksheetsid" name="worksheetsid" value="${projectworksheets.id}"/>
<input type ="hidden" name="fromModel" id="fromModel" value="${projectworksheetsForm.fromModel}"/>

<table cellspacing="0" cellpadding="0" width="98%" align="center"  border="0" class="margtb5">
    <tr>
      <td align="left" class="padl5 lan12"><img src="<%=path%>/images/img-11.gif" width="12" height="12">&nbsp;项目管理 &gt; 立项管理 &gt; 开发任务书 &gt; 编辑</td>
  </tr>
</table>
<table width="98%" align="center" border="0" cellspacing="0" cellpadding="0" class="margb5">
	<tr>
	  <td width="18%" align="center" class="objgy_zi1" id="objgy1" style="cursor:hand;" onclick="bianGY(this.id,'nrgy1')">基本信息</td>
	     <td width="18%" align="center" class="objgy_zi2" id="objgy3" style="cursor:hand;" onclick="bianGY(this.id,'nrgy3')">进度计划</td>
	  <td width="20%" align="center" class="objgy_zi2" id="objgy2" style="cursor:hand;" onclick="bianGY(this.id,'nrgy2')">项目组成员</td>
	  	   <td align="right" ><span >
        &nbsp;
    </span></td>
	</tr>
	<tr>
	  <td colspan="5">
		<table cellspacing="1" cellpadding="0" width="100%" align="center"  border="0" class="bgcolor2" id="nrgy1" style="display:">
		  <tr class="bgcolor">
			<td width="18%" align="right" class="zi13">任务书编号：<font color="red">*&nbsp;</font></td>
			<td width="32%" align="left" class="pad2 zi13">
		     <input type="text" readonly="true" flag="true" value="${projectworksheets.projectid}"  maxlength="50" id="projectid" valid="required" errMsg="请输入任务书编号！" name="projectid"/></td>
		    <td width="18%" align="right" class="zi13">项目名称：<font color="red">*&nbsp;</font></td>
			<td width="32%" align="left" class="pad2 zi13">
		     <input type="text" flag="true" value="${projectworksheets.projectname}"  maxlength="50" valid="required" errMsg="请输入项目名称！" name="projectname" id="projectname"/>
		     <c:if test="${projectworksheetsForm.fromModel!='approval'}">
		      <input type="button" name="Submit" onclick="chooseProject();" value="选择" class="buttonbg">
		      </c:if>
		      </td>
		  </tr>
		   <tr class="bgcolor">
                      <td width="18%" align="right" class="zi13">起止时间：<font color="red">*&nbsp;</font></td>
                         <td colspan="3" align="left" class="pad2 zi13">
				        <input type="text" flag="true" value="<bean:write name="projectworksheets" property="starttime" format="yyyy-MM-dd"/>" readonly="true" valid="required" errMsg="请输入项目开始时间！" name="starttimeStr" id="starttimeStr" readonly="true" 
									onclick="popUpCalendarDlg(this)" />至
				     <input type="text" flag="true" value="<bean:write name="projectworksheets" property="endtime" format="yyyy-MM-dd"/>" readonly="true" valid="required |dateValidateEarly" compareName="starttimeStr" errMsg="请输入项目结束时间！|项目结束时间不能早于项目开始时间" name="endtimeStr" id="endtimeStr" readonly="true"
									onclick="popUpCalendarDlg(this)" /> </td>
				  </tr>
				  
				  
				  
				  
				  
              <tr class="bgcolor" >
                      <td align="right" class="zi13">项目类别：<font color="red">*&nbsp;</font> </td>
				      <td class="pad2 zi13"><ssh:select firstShow="N" propertyName="bak3" defaultName="${projectworksheets.bak3}" pid="project_category" type="1"/></td>
									
					  <td width="18%" align="right" class="zi13">项目类型：<font color="red">*&nbsp;</font> </td>
                      <td width="32%" class="pad2 zi13">
	                   <ssh:select firstShow="N" id="projectCategory" propertyName="projectCategory" defaultName="${projectworksheets.projectCategory}" pid="project_type" type="1"/>
					 </td>				
			    </tr>
			    
			       <tr class="bgcolor" >
                      <td align="right" class="zi13"><bean:message
									key="com.application.projectrfps.entity.projectrfps.createpage.year"
									bundle="projectrfps" />：<font color="red">*&nbsp;</font> </td>
				      <td class="pad2 zi13">   <html:select property="year">
	                      	 <c:forEach var="i" begin="2005" end="2050" step="1"> 
                                   <c:if test="${projectworksheets.year==i }">
                                   		<option value="<c:out value="${i}" />" selected>${i}</option>
                                   </c:if>
                                   <c:if test="${projectworksheets.year!=i }">
                                   		<option value="<c:out value="${i}" />" >${i}</option>
                                   </c:if>
                               </c:forEach>
	                      </html:select>
	                    </td>
									
					  <td width="18%" align="right" class="zi13">是否有外协：<font color="red">*&nbsp;</font> </td>
                      <td width="32%" class="pad2 zi13">
	                      <ssh:select firstShow="N" propertyName="ifoutsourcing" defaultName="${projectworksheets.ifoutsourcing}" pid="yes_no" type="1"/>
					 </td>				
			    </tr>
               <tr class="bgcolor">
                      <td width="18%" align="right" class="zi13"><bean:message
									key="com.application.projectrfps.entity.projectrfps.createpage.principal"
									bundle="projectrfps" />：<font color="red">*&nbsp;</font> </td>
                      <td width="32%" align="left" class="pad2 zi13">
                   <input type="text" name="principal" id="principal" readonly="true" value="${projectworksheets.principal}"/>
                      <input type="hidden" flag="true"  valid="required" errMsg="请选择项目负责人！" errorTipContent="principal" name="principalid" id="principalid" value="${projectworksheets.principalid}"/>
                      <c:if test="${projectworksheetsForm.fromModel!='approval'}">
                      		<input class="buttonbg" id="sel_department2" type="button" onclick="org_userSelect('<%=path%>','principalid','principal','user','undertakedeparid','undertakedepar')" value="<bean:message key='com.syc.common.equipment.but_select' bundle="resourceB"/>" name="but_select2" />
                      		</c:if>
                       </td>
                      <td width="18%" align="right" class="zi13">承担单位：<font color="red">*&nbsp;</font> </td>
                      <td width="32%" align="left" class="pad2 zi13"><input type="text" name="undertakedepar" id="undertakedepar"  readonly="true" value="${projectworksheets.undertakedepar}" />
                      <input type="hidden" flag="true"  errorTipContent="undertakedepar" valid="required" errMsg="请选择承担单位！" name="undertakedeparid" id="undertakedeparid" value="${projectworksheets.undertakedeparid}"/>
                      <c:if test="${projectworksheetsForm.fromModel!='approval'}">
                      <input class="buttonbg" id="sel_department" type="button"  onclick="org_userSelect('<%=path%>','undertakedeparid','undertakedepar','org')"  value="<bean:message key='com.syc.common.equipment.but_select' bundle="resourceB"/>" name="but_select" />	  </c:if>
                        </td>
                     
                    </tr>
                   <tr class="bgcolor">
                      <td align="right" class="zi13">项目费用（万元）：<font color="red">*&nbsp;</font> </td>
                      	<td align="left" colspan="3" class="pad2 zi13"> 
                      	         <input type="text" flag="true" maxlength="13" valid="required|isWanYuan" errMsg="请输入项目费用！|请输入正确的金额！" name="cost" id="cost" styleClass="text1" value="<bean:write name ='projectworksheets' property='cost' format='######.######'/>"/>                      
                        </td>
                    </tr>
                    <tr class="bgcolor">
                      <td align="right" class="zi13">费用构成及用款计划：<font color="red">*&nbsp;</font> </td>
                      <td colspan="3" align="left" class="pad2 zi13">
                       <textarea name="costcomposing"  id="costcomposing" cols="60" rows="5" flag="true"  valid="required|limitLength" max="200" errMsg="请输入研究内容！|研究内容输入长度不能超过200个汉字">${projectworksheets.costcomposing}</textarea>
                       长度不超过200个字</td>
                    </tr>
                    <tr class="bgcolor">
                      <td align="right"  class="zi13">主要设备、仪器及用途：<font color="red">*&nbsp;</font> </td>
                      <td colspan="3" align="left" class="pad2 zi13">
                        <textarea name="equipment" id="equipment"  cols="60" rows="5" flag="true"  valid="required|limitLength" max="200" errMsg="请输入立项背景！|立项背景输入长度不能超过200个汉字">${projectworksheets.equipment}</textarea>
                     长度不超过200个字</td>
                    </tr>
                 
					    <td colspan="4">
					          <iframe width="100%" height="150px" onload="this.height=show_attachment.document.body.scrollHeight"
							src="<%=path%>/queryAttachment.do?method=queryAttachment&fid=${projectworksheets.id}&type=40002"
											; scrolling="no" frameborder="0" name="show_attachment"
											id="show_attachment"></iframe>
					    </td>
					  </tr>			  
		</table>
		
		                 <p>
		 
		<table width="100%"  align="center" border="0" cellspacing="0" cellpadding="0" class="kuang2" id="nrgy3" style="display:none">
		   <tr>
			<td align="left" class="pad5">
			<table cellspacing="1" id="planTable" cellpadding="0" width="100%" align="center"  border="0" class="bgcolor2 margb5">
		            <tr>
				    <td colspan="4" align="left" class="bkuang zi13b bgcolor2 padl5">进度安排及完成时间</td>
		           </tr>
		    
		     <logic:present name="workPlanList">
		      <logic:iterate id="elementValue" name="workPlanList" indexId="indexIdPlan">
		      
		        <logic:equal name="categoryType" value="24001">
                <tr id="tr${indexIdPlan+1}" class="bgcolor"><td width="8%"  align="right" class="zi13" >时间:</td>
                <td width="25%" colspan="3"  align="left" class="pad2 zi13">
				<ssh:select id="plan${indexIdPlan+1}*startYear" propertyName="plan${indexIdPlan+1}*startYear" dataSource="collection" selectList="${yearSelect}"  type="1" defaultName="${elementValue.startYear}"  firstShow="N"/> 年
				 第<ssh:select id="plan${indexIdPlan+1}*quarter" propertyName="plan${indexIdPlan+1}*quarter" dataSource="collection" selectList="${quarter}"  type="1" defaultName="${elementValue.quarter}"  firstShow="N"/>季度
                 <ssh:select id="plan${indexIdPlan+1}*startMonth" propertyName="plan${indexIdPlan+1}*startMonth" dataSource="collection" selectList="${monthSelect}"  type="1" defaultName="${elementValue.startMonth}"  firstShow="N"/>月　至
                   <ssh:select id="plan${indexIdPlan+1}*endMonth"  propertyName="plan${indexIdPlan+1}*endMonth" dataSource="collection" selectList="${monthSelect}"  type="1" defaultName="${elementValue.endMonth}"  firstShow="N"/>月
                 <!-- input type="text" style="height:18px;" name='plan${indexId+1}*startTimeStr' value="<bean:write name="elementValue"  property="startTimeStr"/>" readonly="true" onclick="popUpCalendarDlg(this)" /-->                
                 </td>  
                </tr>   
                 <tr id="tr${indexIdPlan+1}" class="bgcolor"><td width="8%"  align="right" class="zi13">计划内容:</td>
                 <td width="85%" colspan="3"  align="left" class="pad2 zi13"> 
		         <textarea cols="70" rows="5" flag='true' valid='required|limitLength' max='200'  errMsg='请输入第${indexIdPlan+1}行计划内容！|第${indexIdPlan+1}行计划内容输入长度不能超过200个汉字' name="plan${indexIdPlan+1}*plancontent"><bean:write name="elementValue"  property="plancontent"/></textarea><a href="#" onclick="delPlanRow('${indexIdPlan+1}')">&nbsp;&nbsp;删除</a>     </td>
		       </tr>
		       </logic:equal>
		       
		       <logic:equal name="categoryType" value="24002">

		             <tr id="tr${indexIdPlan+1}" class="bgcolor"><td width="8%"  align="right" class="zi13" >时间:</td>
                <td width="25%"  colspan="3" align="left" class="pad2 zi13">
                 <ssh:select id="plan${indexIdPlan+1}*startYear" propertyName="plan${indexIdPlan+1}*startYear" dataSource="collection" selectList="${yearSelect}"  type="1" defaultName="${elementValue.startYear}"  firstShow="N"/> 年
                 <ssh:select id="plan${indexIdPlan+1}*startMonth"  propertyName="plan${indexIdPlan+1}*startMonth" dataSource="collection" selectList="${monthSelect}"  type="1" defaultName="${elementValue.startMonth}"  firstShow="N"/>月
                 <!-- input type="text" style="height:18px;" name='model${indexId+1}*startTimeStr' value="<bean:write name="elementValue"  property="startTimeStr"/>" readonly="true" onclick="popUpCalendarDlg(this)" /-->                
                 </td>

                </tr>   
                 <tr id="tr${indexIdPlan+1}" class="bgcolor"><td width="8%"  align="right" class="zi13">计划内容:</td>
                 <td width="85%" colspan="3"  align="left" class="pad2 zi13"> 
		    <textarea cols="70" rows="5" flag='true' valid='required|limitLength' max='200'  errMsg='请输入第${indexIdPlan+1}行计划内容！|第${indexIdPlan+1}行计划内容输入长度不能超过200个汉字' name="plan${indexIdPlan+1}*plancontent"><bean:write name="elementValue"  property="plancontent"/></textarea><a href="#" onclick="delPlanRow('${indexIdPlan+1}')">&nbsp;&nbsp;删除</a>     </td>
		   </tr>
		   
		       </logic:equal>
		       
           </logic:iterate>
           </logic:present>  
             </table>
             </td>
             </tr>
					  
	    <tr><td><input class="buttonbg" id="but_save2" type="button" value="增加计划内容" onclick="insertPlanRow()"   name="but_save2"  id="but_save2"/></td>        </tr>
		</table>
		
		
		<table width="100%"  align="center" border="0" cellspacing="0" cellpadding="0" class="kuang2" id="nrgy2" style="display:none">
		  <tr>
			<td align="left" class="pad5">
			<table cellspacing="1" id="teamsTab" cellpadding="0" width="100%" align="center"  border="0" class="bgcolor2 margb5">
			  <tr class="bgcolor1">
                <td align="center" width="10%" class="zi13b">序号</td>
				<td align="center" width="10%" class="zi13b">姓名</td>
				<td align="center" width="17%" class="zi13b">职务/职称</td>
				<td align="center" width="20%" class="zi13b">单位</td>
				<td align="center" width="17%" class="zi13b">角色</td>
				<td align="center" width="20%" class="zi13b">职责、任务</td>
			    <td align="center" width="10%" class="zi13b">操作</td>
			  </tr>
			  
			    <logic:present name="projectTeamsList">
                      <logic:iterate id="projectTeams" name="projectTeamsList" indexId="indexId">
                      <tr class="bgcolor" align="middle" id="trTeams${indexId+1}">
                      
                     <td align="center" class="zi13" width="10%">${indexId+1}</td>     
                <td align="center" class="zi13" width="10%"><input  type='hidden' name='model${indexId+1}*employeeid' id='model${indexId+1}*employeeid' value="${projectTeams.employeeid}"/><input type="text" id='model${indexId+1}*employeename' name='model${indexId+1}*employeename' value='${projectTeams.employeename}' size='10'/><input type="button"  value="选择" class="buttonbg" onclick="org_userSelect('<%=path%>','model${indexId+1}*employeeid','model${indexId+1}*employeename','researcher','model${indexId+1}*headship','model${indexId+1}*departid','model${indexId+1}*departname')">
                </td>
				<td class="padl5 zi13"><input type="text" name='model${indexId+1}*headship' id='model${indexId+1}*headship' maxlength='15' value='${projectTeams.headship}'></td>
				<td class="padl5 zi13"><input  type='hidden' name='model${indexId+1}*departid' id='model${indexId+1}*departid' value="${projectTeams.departid}"/><input type="text" name='model${indexId+1}*departname' id='model${indexId+1}*departname' value='${projectTeams.departname}'></td>
				<td align="center" class="zi13"><ssh:select firstShow="N" propertyName="model${indexId+1}*role" defaultName="${projectTeams.role}" pid="person_level" type="1"/></td>
				<td class="zi13"><textarea rows="2" cols="20" flag='true'  valid='limitLength' max='100' errMsg='第${indexId+1}行的职责、任务输入长度不能超过100个汉字' name="model${indexId+1}*trust">${projectTeams.trust}</textarea></td>
				<td align="center" class="zi13"><input class="buttonbg" type="button" name="id" value="删除" onclick="delRow('${indexId+1}')"/></td>
                      
                      </tr>
                     </logic:iterate>
                     </logic:present>
		
			</table>
			<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td>
				  <input type="button" onclick="insertRow();" name="Submit2" value="新增" class="buttonbg">
				 </td>
			  </tr>
			</table></td>
		  </tr>
		</table></td>
	</tr>
  </table>
  <br><br><br>
<input name='lastIndex' type='hidden' id='lastIndex' value="${projectTeamsCount+1}" />
    <input name='lastIndexPlan' type='hidden' id='lastIndexPlan' value="${workPlanCount+1}"/>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				    <td align="center">
				      <input class="buttonbg" id="but_save" type="submit"
							value="<bean:message key='com.syc.common.projectrfps.save' bundle="projectrfps"/>"
							name="but_save" />
						&nbsp;&nbsp;&nbsp;
				<c:if test="${projectworksheetsForm.fromModel!='approval'}">
					<input class="buttonbg" id="but_save2" type="button" value="提交审核" onclick="return returnSubmits()"  name="but_save2" />
						&nbsp;&nbsp;&nbsp;
				</c:if>
				     <input class="buttonbg" id="but_return" type="button"
							value="<bean:message key='com.syc.common.projectrfps.return' bundle="projectrfps"/>"
							name="but_return" " onClick="javascript:history.go(-1);" />
				  </tr>
				</table>
</html:form>
</body>
</html>


<script>

//提交审核
function returnSubmits(){
    if(validateForm(document.forms[0],'Y'))
	{
	    document.forms[0].action="projectworksheets/startFolw.do?method=addStartFlow&type=add";
	    document.forms[0].submit();
		return true;
		
	}else{
	    return false;
	}
	
}
function save(){
    var syncHelper = new SyncHelper();
	var type = syncHelper.selectedValue("projectCategory");
	if(validateForm(document.forms[0],'Y'))
	{   
		
	}else{
	    return false;
	}
	if(type=="24001"){ //一般项目
	   if(!checkTime()){
	        bianGY('objgy3','nrgy3');
	   		return false;
       }
	}else{
    	   if(!checkMonth()){
	        bianGY('objgy3','nrgy3');
	   		return false;
       }
    }
	return true;
}

/**
  增加一行
**/
function insertRow(){
    var lastIndex = $('lastIndex').value;
        var addrow = $('teamsTab').insertRow();
        addrow.className = "bgcolor";
        var addcellone = addrow.insertCell();
	    addcellone.setAttribute("align","center");
	    addrow.setAttribute("id","trTeams"+lastIndex);  
		addcellone.innerHTML = lastIndex;
		addcellone = addrow.insertCell();
		addcellone.setAttribute("align","center");
		addcellone.innerHTML = "<input  type='hidden' id='model"+ lastIndex +"*employeeid' name='model"+ lastIndex +"*employeeid' /><input readonly='true' flag='true'  valid='required' size='10' errMsg='请输入第"+lastIndex+"行的姓名！' type='text' id='model"+ lastIndex +"*employeename' name='model"+ lastIndex +"*employeename'/><input type='button'  value='选择' class='buttonbg' onclick='org_userSelect(\"<%=path%>\",\"model"+ lastIndex +"*employeeid\",\"model"+ lastIndex +"*employeename\",\"researcher\",\"model"+ lastIndex +"*headship\",\"model"+ lastIndex +"*departid\",\"model"+ lastIndex +"*departname\")'>";
	    addcellone = addrow.insertCell();
	    addcellone.setAttribute("align","center");
		addcellone.innerHTML = "<input type='text' maxlength='15' id='model"+ lastIndex +"*headship' name='model"+ lastIndex +"*headship'/>";
		addcellone = addrow.insertCell();
		addcellone.setAttribute("align","center");
		addcellone.innerHTML = "<input  type='hidden' id='model"+ lastIndex +"*departid' name='model"+ lastIndex +"*departid'/><input flag='true' readonly='true'  valid='required' errMsg='请输入第"+lastIndex+"行的单位！' type='text' id='model"+ lastIndex +"*departname' name='model"+ lastIndex +"*departname'/>";
		addcellone = addrow.insertCell();
		addcellone.setAttribute("align","center");
		addcellone.innerHTML = person_level_map.toSelect("model"+ lastIndex +"*role");
		addcellone = addrow.insertCell();
		addcellone.setAttribute("align","center");
		addcellone.innerHTML = "<textarea rows='2' flag='true'  valid='limitLength' max='100' errMsg='第"+lastIndex+"行的职责、任务输入长度不能超过100个汉字' cols='20' id='model"+ lastIndex +"*trust' name='model"+ lastIndex +"*trust'></textarea>";
		addcellone = addrow.insertCell();
		addcellone.innerHTML = "<input type='button' class='buttonbg' name='id' value='删除' onclick='delRow(" + lastIndex + ")'/>";
		$('lastIndex').value = parseInt(lastIndex) + 1;

   
}

function delRow(index){
	var tableTeams = $('teamsTab');
	var rowTeams = $('trTeams' + index);
	var rowIndexs = rowTeams.rowIndex;
	tableTeams.deleteRow(rowIndexs); 	
    for(var i=rowIndexs;i<tableTeams.rows.length;i++){
       tableTeams.rows[i].cells[0].innerHTML = i.toString();
    }
    $('lastIndex').value = tableTeams.rows.length;

}

function chooseProject(){   
    var syncHelper = new SyncHelper();
	var url = "popuSelectProjectrfps.do?method=popuSelectProjectrfps&random=" + Math.random() + "&random2=" + Math.random();
	var searchWin = window.showModalDialog(url,window,"help:no;scroll:yes;resizable:no;status:0;dialogWidth:1000px;dialogHeight:600px;center:yes" ); 	
    if(searchWin){		 
		 $("projectname").value = searchWin["projectname"]==undefined?"":searchWin["projectname"];
		 $("rfpsid").value = searchWin["id"]==undefined?"":searchWin["id"];
		 $("principalid").value = searchWin["principalid"]==undefined?"":searchWin["principalid"];
		 $("principal").value = searchWin["principal"]==undefined?"":searchWin["principal"];
		 $("undertakedepar").value = searchWin["departname"]==undefined?"":searchWin["departname"];
		 $("undertakedeparid").value = searchWin["departid"]==undefined?"":searchWin["departid"];
		 $("starttimeStr").value = searchWin["starttime"]==undefined?"":searchWin["starttime"];
		 $("endtimeStr").value = searchWin["endtime"]==undefined?"":searchWin["endtime"];
		 $("equipment").value = searchWin["equipment"]==undefined?"":searchWin["equipment"];
		 $("costcomposing").value = searchWin["costStruct"]==undefined?"":searchWin["costStruct"];
		 $("cost").value = searchWin["cost"]==undefined?"":searchWin["cost"];
		 syncHelper.selectedByValue(searchWin["projecttype"],"projectCategory");
		 syncHelper.selectedByValue(searchWin["year"],"year");
    }
}





/**
  增加一行
**/
function insertPlanMonthRow(){

    var lastIndex = $('lastIndexPlan').value;
    var addrow = $('planTable').insertRow();
  	addrow.className="bgcolor";
    var addcellone = addrow.insertCell();
    addcellone.className="zi13";
    addcellone.setAttribute("align","right");
    
    addrow.setAttribute("id","tr"+lastIndex);  
	addcellone.innerHTML = '时间:';
	addcellone = addrow.insertCell();
	addcellone.className="pad2 zi13";
	addcellone.setAttribute("align","left");
	addcellone.colSpan =3;
	addcellone.innerHTML = "&nbsp;<ssh:select id='plan"+lastIndex+"*startYear' propertyName='plan"+lastIndex+"*startYear' dataSource='collection' selectList='${yearSelect}'  type='1' defaultName='${isSelect}'  firstShow='N'/> 年 <ssh:select id='plan"+lastIndex+"*startMonth' propertyName='plan"+lastIndex+"*startMonth' dataSource='collection' selectList='${monthSelect}'  type='1' defaultName=''  firstShow='N'/>月";
  
	
	var addrow = $('planTable').insertRow();
	addrow.className="bgcolor";
	var addcellone = addrow.insertCell();
    addcellone.className="zi13";
    addcellone.setAttribute("align","right");
    
    addrow.setAttribute("id","tr"+lastIndex);  
	addcellone.innerHTML = '计划内容:';
	addcellone = addrow.insertCell();
	addcellone.colSpan =3;
	addcellone.className="pad2 zi13";
	addcellone.setAttribute("align","left");
	
	addcellone.innerHTML = "<textarea cols='70' rows='5' flag='true' valid='required|limitLength' max='200'  errMsg='请输入第"+lastIndex+"行计划内容！|第"+lastIndex+"行计划内容输入长度不能超过200个汉字' name='plan"+ lastIndex +"*plancontent' id='plan"+ lastIndex +"*plancontent'></textarea><a href='#' onclick='delPlanRow("+lastIndex+")'>&nbsp;&nbsp;删除</a>";
	$('lastIndexPlan').value = parseInt(lastIndex) + 1;	
}

function delPlanRow(index){
   var table = $('planTable');
   var row = $('tr' + index);
   var rowIndex = row.rowIndex;
   table.deleteRow(rowIndex); 
   var table = $('planTable');
   var row = $('tr' + index);
   var rowIndex = row.rowIndex;
   table.deleteRow(rowIndex); 
   $('lastIndexPlan').value = table.rows.length;
}


function insertPlanQuarterRow(){
    
    var lastIndex = $('lastIndexPlan').value;
    var addrow = $('planTable').insertRow();
  	addrow.className="bgcolor";
    var addcellone = addrow.insertCell();
    addcellone.className="zi13";
    addcellone.setAttribute("align","right");
    addrow.setAttribute("id","tr"+lastIndex);  
	addcellone.innerHTML = '时间:';
	addcellone = addrow.insertCell();
	addcellone.className="pad2 zi13";
	addcellone.setAttribute("align","left");
	addcellone.colSpan =3;
	addcellone.innerHTML = "&nbsp;<ssh:select id='plan"+lastIndex+"*startYear' propertyName='plan"+lastIndex+"*startYear' dataSource='collection' selectList='${yearSelect}'  type='1' defaultName='${isSelect}'  firstShow='N'/> 年 第<ssh:select id='plan"+lastIndex+"*quarter' propertyName='plan"+lastIndex+"*quarter' dataSource='collection' selectList='${quarter}'  type='1' defaultName='${elementValue.quarter}'  firstShow='N'/>季度 <ssh:select id='plan"+lastIndex+"*startMonth' propertyName='plan"+lastIndex+"*startMonth' dataSource='collection' selectList='${monthSelect}'  type='1' defaultName='${elementValue.startMonth}'  firstShow='N'/>月　至  <ssh:select id='plan"+lastIndex+"*endMonth' propertyName='plan"+lastIndex+"*endMonth' dataSource='collection' selectList='${monthSelect}'  type='1' defaultName='${elementValue.endMonth}'  firstShow='N'/>月";
	var addrow = $('planTable').insertRow();
	addrow.className="bgcolor";
	var addcellone = addrow.insertCell();
    addcellone.className="zi13";
    addcellone.setAttribute("align","right");
    addrow.setAttribute("id","tr"+lastIndex);  
	addcellone.innerHTML = '计划内容:';
	addcellone = addrow.insertCell();
	addcellone.colSpan =3;
	addcellone.className="pad2 zi13";
	addcellone.setAttribute("align","left");
	addcellone.innerHTML = "<textarea cols='70' rows='5' flag='true' valid='required|limitLength' max='200'  errMsg='请输入第"+lastIndex+"行计划内容！|第"+lastIndex+"行计划内容输入长度不能超过200个汉字' name='plan"+ lastIndex +"*plancontent'></textarea><a href='#' onclick='delPlanRow("+lastIndex+")'>&nbsp;&nbsp;删除</a>";
	$('lastIndexPlan').value = parseInt(lastIndex) + 1;
}

function insertPlanRow(){
	var syncHelper = new SyncHelper();
	var type = syncHelper.selectedValue("projectCategory");
	if(type=="24002"){ //重点项目
	    insertPlanMonthRow();
	}else{
		insertPlanQuarterRow();
	}
}


function checkTime(){
  var lastIndex = $('lastIndexPlan').value-1;
for(var i=1;i<lastIndex+1;i++){
	var startMonth=document.getElementsByName('plan'+i+'*startMonth')[0];
  
	startMonth=startMonth.options[startMonth.selectedIndex].value;

	var endMonth=document.getElementsByName('plan'+i+'*endMonth')[0];
	endMonth=endMonth.options[endMonth.selectedIndex].value;
	
	var quarter=document.getElementsByName('plan'+i+'*quarter')[0];
	quarter=quarter.options[quarter.selectedIndex].value;
	var year = document.getElementsByName('plan'+i+'*startYear')[0];
	year=year.options[year.selectedIndex].value;
	
		if(endMonth<startMonth){
			alert('请检查第'+i+'项计划选择是否正确，结束月不能小于开始月');
			return false;
		}
	for(var j=i+1;j<lastIndex+1;j++){
	
		var quarters=document.getElementsByName('plan'+j+'*quarter')[0];
		var years=document.getElementsByName('plan'+j+'*startYear')[0];
		quarters=quarters.options[quarters.selectedIndex].value;
		years=years.options[years.selectedIndex].value;
		if(quarter==quarters && year==years){
			alert('季度不能重复');
			return false;
		}
	
	}
	
		if(endMonth<startMonth){
			alert('请检查第'+i+'项计划选择是否正确，结束月不能小于开始月');
			return false;
		}

	
	if(quarter=='1'){
		if(endMonth>3 ||startMonth>3){
			alert('请检查第'+i+'项计划选择是否正确，月份必须在选择季度范围内');
			return false;
		}
	}
		if(quarter=='2'){
		if(startMonth<4 || startMonth>6 || endMonth<4 || endMonth>6 ){
			alert('请检查第'+i+'项计划选择是否正确，月份必须在选择季度范围内');
			return false;
		}
	}
	
	if(quarter=='3'){
		if(startMonth<7 || startMonth>9 || endMonth<7 || endMonth>9 ){
			alert('请检查第'+i+'项计划选择是否正确，月份必须在选择季度范围内');
			return false;
		}
	}
	if(quarter=='4'){
		if(startMonth<10 || startMonth>12 || endMonth<10 || endMonth>12){
			alert('请检查第'+i+'项计划选择是否正确，月份必须在选择季度范围内');
			return false;
		}
	}

}

return true;
}



function checkMonth(){

       var lastIndex = $('lastIndexPlan').value-1;
	for(var i=1;i<lastIndex+1;i++){
		var startYear=document.getElementsByName('plan'+i+'*startYear')[0];
		startYear=startYear.options[startYear.selectedIndex].value;
	
		var startMonth=document.getElementsByName('plan'+i+'*startMonth')[0];
		startMonth=startMonth.options[startMonth.selectedIndex].value;
	
		for(var j=i+1;j<lastIndex+1;j++){
		var nextYear=document.getElementsByName('plan'+j+'*startYear')[0];
		nextYear=nextYear.options[nextYear.selectedIndex].value;
	
		var nextMonth=document.getElementsByName('plan'+j+'*startMonth')[0];
		nextMonth=nextMonth.options[nextMonth.selectedIndex].value;
		if((startYear+""+startMonth)==(nextYear+""+nextMonth)){
			alert('填写的年月不能重复');
			return false;
		}
		}
	}
	return true;
}
</script>





